package com.bestcem.xm.ticket.controller.vo.ticket;

import com.bestcem.xm.ticket.enums.TicketStatusEnum;
import com.bestcem.xm.ticket.enums.TicketTypeEnum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/**
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/9/9 22:45
 */
@Data
public class TicketInfoVO {
    @JsonProperty(value = "id")
    private String id;

    /**
     * 工单名称，2.3新增
     */
    private String name;

    /**
     * 1-系统创建，2-手动创建（2.3版本新增）
     */
    @JsonProperty(value = "operation_type")
    private Integer operationType;

    /**
     * ticketNo 最大长度 32,格式：yyyymmdd00001
     */
    @JsonProperty(value = "ticketNo")
    private String ticketNo;

    /**
     * regionName
     */
    @JsonProperty(value = "regionName")
    private String regionName;

    /**
     * 问卷标题
     */
    @JsonProperty(value = "surveyTitle")
    private String surveyTitle;

    /**
     * status
     *
     * @see TicketStatusEnum
     */
    @JsonProperty(value = "status")
    private Integer status;

    /**
     * contact
     * <p>
     * 这个字段我不知道怎么写, python里面是 dict 类型, 但是库里没有数据, 所以我不知道到底是个什么样子
     * 沟通记录: @赵明: 这个是历史字段了，我接手后，也没用过
     */
    @JsonProperty(value = "contact")
    private ContactVO contact;

    /**
     * contact
     * <p>
     * 这个字段我不知道怎么写, python里面是 dict 类型, 但是库里没有数据, 所以我不知道到底是个什么样子
     * 沟通记录: @赵明: 这个是历史字段了，我接手后，也没用过
     */
    @JsonProperty(value = "alertRules")
    private List<AlertRuleVO> alertRules;

    /**
     * closedDT
     */
    @JsonProperty(value = "closedDT")
    private Date closedDate;

    /**
     * hasFollowOverdue
     */
    @JsonProperty(value = "hasFollowOverdue")
    private Boolean hasFollowOverdue;

    /**
     * followDeadline
     */
    @JsonProperty(value = "followDeadline")
    private Date followDeadline;

    @JsonProperty(value = "isLastAuditNode")
    private Boolean lastAuditNode;

    @JsonProperty(value = "auditDeadline")
    private Date auditDeadline;

    @JsonProperty(value = "hasAuditOverdue")
    private Boolean hasAuditOverdue;

    @JsonProperty(value = "ticketRecords")
    private List<TicketRecordVO> ticketRecords;

    @JsonProperty(value = "ticketTemplate")
    private TicketTemplateVO ticketTemplate;

    @JsonProperty(value = "currentUsersIds")
    private List<String> currentUsersIds;

    @JsonProperty(value = "alertrecord_id")
    private String alertRecordId;

    @JsonProperty(value = "currentUsers")
    private List<String> currentUsers;

    @JsonProperty(value = "templateDetailFields")
    private List<TemplateDetailFieldVO> templateDetailFields;

    @JsonProperty(value = "followerFilter")
    private Integer followerFilter;

    /**
     * ttype
     *
     * @see TicketTypeEnum
     */
    @JsonProperty(value = "ttype")
    private Integer type;

    /**
     * 是否至少需要一次提交记录
     */
    @JsonProperty(value = "needRecord")
    private Boolean needRecord;

    /**
     * 是否已有跟进记录
     */
    @JsonProperty(value = "hasCommit")
    private Boolean hasCommit;

    /**
     * 详情模板id（新加字段）
     */
    @JsonProperty(value = "detailTemplateId")
    private String detailTemplateId;

    /**
     * 创建人名字
     */
    @JsonProperty(value = "created_name")
    private String createdName;

    /**
     * 工单满足的触发条件的名称
     * 2022-02-18 行动新增条件名称需求新增
     */
    @JsonProperty(value = "trigger_names")
    private LinkedList<String> triggerNames;

    /**
     * 数据记录标记
     */
    @JsonProperty(value = "record_flag")
    private Integer recordFlag = 1;
    @JsonProperty(value = "created_dt")
    private Date createdDate;
    @JsonProperty(value = "created_id")
    private String createdId;
    @JsonProperty(value = "updated_dt")
    private Date updatedDate;
    @JsonProperty(value = "updated_id")
    private String updatedId;


    // ================================================================


    /**
     * 工单详情 显示内容
     *
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @version v1.0
     * @date 2021/8/10 17:50
     */
    @Data
    public static class TemplateDetailFieldVO {
        @JsonProperty(value = "name")
        private String name;

        @JsonProperty(value = "sourceId")
        private String sourceId;

        @JsonProperty(value = "originText")
        private String originText;

        @JsonProperty(value = "value")
        private Value value;

        @Data
        public static class Value {

            @JsonProperty(value = "answer")
            private Object answer;

            @JsonProperty(value = "custom_qtype")
            private String customType;

            @JsonProperty(value = "qtype")
            private String type;

            @JsonProperty(value = "cid")
            private String cid;
        }
    }

    /**
     * 联系人信息
     */
    @Data
    public static class ContactVO {
        /**
         * 手机号
         */
        @JsonProperty(value = "phone")
        private String phone;

        /**
         * 邮箱
         */
        @JsonProperty(value = "email")
        private String email;
    }

    @AllArgsConstructor
    @NoArgsConstructor
    @Data
    public static class AlertRuleVO {
        @JsonProperty(value = "alertRuleId")
        private String alertRuleId;

        @JsonProperty(value = "alertRuleTitle")
        private String alertRuleTitle;
    }
}
